<template>
	<view class="team-info">
		<view class="list" style="width: 100%;">
			<team-info-item v-for="item in list" :key="item.id" :data="item">
				<template #right>
					<view class="right flex-grow-1">
						<view class="" style="display: flex;flex-direction: row;justify-content: flex-end;">
							<image style="width: 30rpx; height: 30rpx;margin-right: 20rpx;" :src="bianji" mode=""
								@click="bfEdit(item)"></image>
							<image style="width: 30rpx; height: 30rpx;" :src="shanchu" mode="" @click="bfDel(item)">
							</image>
						</view>
					</view>
				</template>
			</team-info-item>
		</view>

		<view class="bottom-add-btn">
			<u-button text="添加赛队" shape="circle" @click="add"
				color="linear-gradient( 270deg, #47B37B 0%, #69D19B 100%, #4BA677 0%)"></u-button>
		</view>
	</view>
</template>

<script>
	const venues = require("@/api/venues/venues.js");
	import {
		getCurrentPath
	} from '@/utils/util.js';
	export default {
		data() {
			return {
				list: [],
				bianji: 'https://oss.szsportscenter.cn/img/7886aba3ece8aae3b489b1944b48572a4f092c41.png',
				shanchu: 'https://oss.szsportscenter.cn/img/fe85ef51643a187a6090a929b34e93738e12e365.png',

			}
		},
		onLoad() {
			this.getTeamList()

		},
		onShow() {
			this.getTeamList()
		},
		methods: {
			bfDel(item) {
				let that = this
				uni.showModal({
					title: '删除',
					content: '是否确定删除！',
					success: function(res) {
						if (res.confirm) {
							let params = {
								project_id: getApp().globalData.projectId,
								app_id: that.$https.weixinAppId,
								open_id: uni.getStorageSync("openid"),
								id: item.id,
							}
							venues.delTeam(params).then(res => {
								if (res.code == 1) {
									that.getTeamList()
								}
							})
						} else if (res.cancel) {
						}
					}
				});

			},
			// 获取队伍列表
			async getTeamList() {
				let params = {
					open_id: uni.getStorageSync("openid"),
					project_id: getApp().globalData.projectId,
					app_id: this.$https.weixinAppId,
				}
				let res = await venues.getTeamList(params)
				if (res.code == 1) {
					this.list = res.data.result.itemArr
				}
			},
			bfEdit(item) {
				// uni.navigateTo({
				// 	url: '/page_venues/pages/member-info/add/add?id=' + item1.id
				// });
				uni.navigateTo({
					url: '/page_venues/pages/team-info/add/add?item=' + encodeURIComponent(JSON.stringify(item))
				});
			},
			add() {
				uni.navigateTo({
					url: '/page_venues/pages/team-info/add/add?type=' + 1
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.team-info {
		min-height: 100vh;
		background-color: #EDF5F5;
		padding: 30rpx;
		padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
	}

	.bottom-add-btn {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		padding: 20rpx;
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
		background-color: #fff;
		z-index: 1;
	}
</style>